<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>商品列表</title>
</head>
<body>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet"
      href="${pageContext.request.contextPath}/static/css/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet"
      href="${pageContext.request.contextPath}/static/css/bootstrap/css/default.css">
<!-- Custom styles for this template -->
<link href="${pageContext.request.contextPath}/static/css/carousel.css"
      rel="stylesheet">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.js"></script>
<script src="${pageContext.request.contextPath}/static/js/functions.js"></script>
<script src="${pageContext.request.contextPath}/static/js/cart.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="${pageContext.request.contextPath}/static/css/bootstrap/js/bootstrap.min.js"></script>

<c:import url="../common/userTopNav.jsp"/>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-2">
            <c:import url="../common/address_left_nav.jsp"/>
        </div>
        <div class="col-md-10">
            <div>
                <button class="btn btn-primary" type="submit" onclick="handleAddressForm()">添加收货地址</button>
            </div>
            <table class="table table-condensed table-hover">
                <thead>
                <tr>
                    <th>#</th>
                    <th>省-市-区</th>
                    <th>街道</th>
                    <th>收件人</th>
                    <th>电话</th>
                    <th>默认地址</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:if test="${not empty addressList}">
                    <c:forEach items="${addressList}" var="address" varStatus="status">
                        <tr>
                            <td>${status.count}</td>
                            <td>${address.pca}</td>
                            <td>${address.addr.street}</td>
                            <td>${address.addr.receiver}</td>
                            <td>${address.addr.telephone}</td>
                            <td class="isDefault">${address.addr.type==1?"默认地址":""}</td>
                            <td>
                                <a href="#" onclick="handleAddressForm(${address.addr.aid})">修改</a> |
                                <a href="${pageContext.request.contextPath}/address/deleteAddress?aid=${address.addr.aid}"
                                   onclick="return confirm('确定要删除这个收货地址吗？')">删除
                                </a> |
                                <a href="#" onclick="setDefault(${address.addr.aid},event)">设为默认地址</a>
                            </td>
                        </tr>
                    </c:forEach>
                </c:if>
                </tbody>
            </table>
            <c:if test="${empty addressList}">
                <h2><center>您还未添加收货地址呢</center></h2>
            </c:if>
        </div>
    </div>
</div>


<c:import url="../common/addressModal.jsp"/>

<c:import url="../common/userFooter.jsp"/>
</body>
</html>